package com.roc.steelend.controller;


import com.roc.steelend.controller.vo.common.BuyByRecoding;
import com.roc.steelend.controller.vo.common.InventoryByRecoding;
import com.roc.steelend.controller.vo.common.InventorySpecialReception;
import com.roc.steelend.controller.vo.returnformat.ReturnMsgForTable;
import com.roc.steelend.service.InventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

@RestController
@Api(tags = "库存功能接口")
@CrossOrigin
public class InventoryController {

   @Autowired
   private InventoryService inventoryService;

    @GetMapping("/v1/inventory/kaiping")
    public ReturnMsgForTable findInventoryKaiPing(@RequestParam(required = true,value = "pageSize") Integer pageSize,
                                                  @RequestParam(required = true,value = "currentPage") Integer currentPage,
                                                  @RequestParam(required = false,value = "smallTypeId")Integer smallTypeId,
                                                  @RequestParam(required = false,value = "warehouseId")Integer warehouseId,
                                                  @RequestParam(required = false,value = "thickness")BigDecimal thickness,
                                                  @RequestParam(required = false,value = "weight")BigDecimal weight) throws InterruptedException {
//        Thread.sleep(1000);
        return inventoryService.findJuanBanByKaiPing(currentPage,pageSize,smallTypeId,warehouseId,thickness,weight);
    }

    @GetMapping("/v1/inventory/findid")
    public List<HashMap<String,Object>> findInventoryById(@RequestParam(required = true,value = "inventoryId")Integer inventoryId){


            return  inventoryService.findInventoryById(inventoryId);

    }



//
@PostMapping("/v1/inventory/recording")
@ApiOperation(value = "库存查询接口(ps:特殊情况使用post,但不修改数据!!!)",notes = "可选择性填一个所有信息查询器的类(ps:特殊情况使用post,但不修改数据!!!)")
private ReturnMsgForTable inventoryFindRecoding( @RequestBody(required = false)@ApiParam(value = "条件选择器类",required = false) InventoryByRecoding selectMsg){

    ReturnMsgForTable returnMsgForTable = new ReturnMsgForTable();
    returnMsgForTable.setCurrenPage(selectMsg.getCurrentPage());
    returnMsgForTable.setObjectList( inventoryService.inventoryFindRecoding(selectMsg));
    returnMsgForTable.setTotal(inventoryService.inventoryFindRecodingCount(selectMsg));
    return returnMsgForTable;
}


    @PostMapping("/v1/inventory/recording/daigang")
    @ApiOperation(value = "带钢/平板库存查询接口(ps:特殊情况使用post,但不修改数据!!!)",notes = "可选择性填一个所有信息查询器的类(ps:特殊情况使用post,但不修改数据!!!)")
    private ReturnMsgForTable daigangpingbanInventoryFindRecoding( @RequestBody(required = false)@ApiParam(value = "条件选择器类",required = false) InventorySpecialReception inventorySpecialReception){
        System.out.println(inventorySpecialReception);

        ReturnMsgForTable returnMsgForTable = new ReturnMsgForTable();
        returnMsgForTable.setCurrenPage(inventorySpecialReception.getCurrentPage());
        returnMsgForTable.setObjectList( inventoryService.daigangpingbanInventoryFindRecoding(inventorySpecialReception));
        returnMsgForTable.setTotal(inventoryService.daigangpingbanInventoryFindRecodingCount(inventorySpecialReception));
        return  returnMsgForTable;
    }


    @GetMapping("/v1/inventory/warehouse/3")
    @ApiOperation(value = "库存报警查询")
    public List<HashMap<String,Object>>  inventoryWarehouse3(){
        List<HashMap<String, Object>> hashMaps = inventoryService.inventoryWarehouse3();
        if (hashMaps.isEmpty()){
            return  null;
        }else {
            return hashMaps;
        }
    }
}
